<?php

//抽象基类
abstract class jilei {
	private guancha = [];
	//增加观察者
	public function add (jiekou $id) {
		$this->guancha[] = $id;
	}
	//通知消息
	public funciton notify () {
		
		foreach ($this->guancha as $no ) {
			$no->update();
		}
	}
}

//接口类

interface jiekou {

	 function update ($b = null) {}
}

//调用类
class diaoyong  extends jilei {

	function trigger () {
		$this->notify();
	}
}

//发送消息类

class jieshou implements jiekou {

	function update ($b = null) {
		echo 'fasong'; 
	}
}


$diaoyong = new diaoyong ();
$diaoyong->add(new jieshou);
$diaoyong->trigger();
